Data Types
Data types are defined within the common elements of
Why Data Typing?
Data typing is implemented to define the type of any parameter used. This helps prevent errors early on in the programming phase (e.g., avoids dividing a Date by an Integer).
When you have defined whether the data is a string, a date, an integer or a 16-bit Boolean input, there is no longer any confusion, nor any conflict between different people using the textual representation (i.e., the name of the variable).
Different Data Types
- Common Data Types: Boolean, Byte, Date, Integer, Real, String, Time_of_Day, Word.
- Derived Data Types: Define personal data types based on the Common data types.
- Example: Define an analog input channel as a data type and re-use it.
List of Data Types
Type |
Prefix |
Description |
Values |
BOOL |
|
Boolean (bit) |
|
BYTE |
|
Same as USINT. |
|
DINT |
|
Signed double precision integer in 32-bits. |
-2147483648 to 2147483647 |
DWORD |
|
Same as UDINT. |
|
INT |
INT# |
Signed integer in 16-bits. |
-32768 to +32767 |
LINT |
LINT# |
Long signed integer in 64-bits. |
|
LREAL# |
Double precision floating point stored in 64-bits. |
|
|
LWORD |
|
Same as ULINT. |
|
REAL# ‡‡ |
Single precision floating point stored in 32-bits. |
|
|
SINT |
SINT# |
Small signed integer in 8-bits. |
-128 to +127 |
STRING |
|
Variable length string with declared maximum length. Each character is store on 1 byte (i.e., on 8-bits). |
Maximum length cannot exceed 255 characters. |
T# or TIME# |
Time data type is used to specify a time variable.
|
0ms - 24hr |
|
UDINT# |
Unsigned integer in 32-bits. |
0 to +4294967295 |
|
UINT# |
Unsigned integer in 16-bits. |
0 to 65535 |
|
ULINT# |
Long unsigned integer in 64-bits. |
|
|
USINT# |
Small unsigned integer in 8-bits. |
0 to 255 |
|
WORD |
|
Same as UINT. |
|
WSTRING |
|
Do not use! The WSTRING is not supported. |
|
-
-
‡ REAL variables are limited to 6 digits of accuracy.
To achieve greater accuracy, a longer mantissa may be specified by prefixing LREAL with #.Example: To achieve an accuracy of 20 digits for the value of Pi, rather than what REAL provides (3.14159), set the type to
LREAL#3.141592653589793238
.
-
-
‡‡ REAL is restrictive, but because it is the default, it is recommended to explicitly declare real constants with the LREAL# prefix.